home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / filechooser / UnixFileSystemView.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  2.8 KB  |  90 lines

  1. package javax.swing.filechooser;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.lang.reflect.Method;
  6.  
  7. class UnixFileSystemView extends FileSystemView {
  8.    private static final Object[] noArgs = new Object[0];
  9.    private static final Class[] noArgTypes = new Class[0];
  10.    private static Method listRootsMethod = null;
  11.    private static boolean listRootsMethodChecked = false;
  12.    // $FF: synthetic field
  13.    static Class class$java$io$File;
  14.  
  15.    // $FF: synthetic method
  16.    static Class class$(String var0) {
  17.       try {
  18.          return Class.forName(var0);
  19.       } catch (ClassNotFoundException var2) {
  20.          throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  21.       }
  22.    }
  23.  
  24.    public File createNewFolder(File var1) throws IOException {
  25.       if (var1 == null) {
  26.          throw new IOException("Containing directory is null:");
  27.       } else {
  28.          Object var2 = null;
  29.          File var4 = ((FileSystemView)this).createFileObject(var1, "NewFolder");
  30.  
  31.          for(int var3 = 1; var4.exists() && var3 < 100; ++var3) {
  32.             var4 = ((FileSystemView)this).createFileObject(var1, "NewFolder." + var3);
  33.          }
  34.  
  35.          if (var4.exists()) {
  36.             throw new IOException("Directory already exists:" + var4.getAbsolutePath());
  37.          } else {
  38.             var4.mkdirs();
  39.             return var4;
  40.          }
  41.       }
  42.    }
  43.  
  44.    public File[] getRoots() {
  45.       if (!listRootsMethodChecked) {
  46.          try {
  47.             listRootsMethod = (class$java$io$File != null ? class$java$io$File : (class$java$io$File = class$("java.io.File"))).getMethod("listRoots", noArgTypes);
  48.          } catch (NoSuchMethodException var6) {
  49.          } finally {
  50.             listRootsMethodChecked = true;
  51.          }
  52.       }
  53.  
  54.       if (listRootsMethod != null) {
  55.          try {
  56.             File[] var1 = (File[])listRootsMethod.invoke((Object)null, noArgs);
  57.  
  58.             for(int var2 = 0; var2 < var1.length; ++var2) {
  59.                var1[var2] = new FileSystemRoot(var1[var2]);
  60.             }
  61.  
  62.             return var1;
  63.          } catch (Exception var8) {
  64.             ((Throwable)var8).printStackTrace();
  65.          }
  66.       } else {
  67.          File[] var9 = new File[]{new File("/")};
  68.          if (var9[0].exists() && var9[0].isDirectory()) {
  69.             return var9;
  70.          }
  71.       }
  72.  
  73.       return null;
  74.    }
  75.  
  76.    public boolean isHiddenFile(File var1) {
  77.       if (var1 != null) {
  78.          String var2 = var1.getName();
  79.          return var2.charAt(0) == '.';
  80.       } else {
  81.          return false;
  82.       }
  83.    }
  84.  
  85.    public boolean isRoot(File var1) {
  86.       String var2 = var1.getAbsolutePath();
  87.       return var2.length() == 1 && var2.charAt(0) == '/';
  88.    }
  89. }
  90.